<template>
    <div class="page-profile">
        <UserInfo />
        <ProfileInfo />
        <CouPon />
        <Promotion />
    </div>
</template>

<script>
import UserInfo from "./components/userInfo/index";
import ProfileInfo from "./components/profileInfo/index";
import CouPon from "./components/coupon/index";
import Promotion from "./components/promotion/index";
export default {
    name: "profile",
    components: {
        UserInfo,
        ProfileInfo,
        CouPon,
        Promotion
    },

    data() {
        return {
            showVant: true
        };
    },

    created() {
        const wfLogin = wf.getModule("login");
        wfLogin.login().then(res => {
            this.$store.commit("updateUserInfo", {
                ...res,
                deviceId: wf.getModule("reporter").getDeviceId()
            });
            console.log("login", this.$store.state.userInfo);
            if (res.isLogin) {
                this.getUserInfo();
            }
        });

        this.$bus.$on("updateUserInfo", () => {
            this.getUserInfo();
        });

        // test
        console.log("this.$route.quer", this.$route.query);
    },

    methods: {
        getUserInfo() {
            this.$cloudApi.getUserInfo().then(res => {
                console.log("getUserInfo", res.data);
                if (res.data.length > 0) {
                    this.$store.commit("updateUserInfo", {
                        ...res.data[0]
                    });
                }
            });
        }
    }
};
</script>


<style scoped>
.page-profile {
    background: #f5f5f5;
    width: 100vw;
    height: 100vh;
    box-sizing: border-box;
    padding: 0 0 110px 0;
}
</style>